package com.flower.hooc.service.impl;

import com.flower.hooc.bean.pojo.entity.Order;
import com.flower.hooc.mapper.OrderMapper;
import com.flower.hooc.service.OrderService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author hyorin
 * @date 2020.9.2
 */
@Service
public class OrderServiceImpl implements OrderService {

    Logger logger = LoggerFactory.getLogger(OrderServiceImpl.class);
    @Autowired
    OrderMapper orderMapper;

    @Override
    public List<Order> selectOrderByUserId(Long id) {
        List<Order> orders = orderMapper.selectOrderByUserId(id);
        if (orders == null) {
            logger.warn("用户id:{} 该用户暂无订单", id);
            throw new RuntimeException("该用户暂无订单");
        }
        return orders;
    }
}
